// 支持的语言列表
export const locales = ['en', 'zh', 'ja', 'ko', 'fr', 'de'] as const;
export type Locale = typeof locales[number];

// 默认语言
export const defaultLocale: Locale = 'en';

// 获取当前语言
export function getCurrentLocale(): Locale {
  if (typeof window === 'undefined') return defaultLocale;
  
  const saved = localStorage.getItem('locale') as Locale;
  if (saved && locales.includes(saved)) {
    return saved;
  }
  
  return defaultLocale;
}

// 设置当前语言
export function setCurrentLocale(locale: Locale) {
  if (typeof window === 'undefined') return;
  
  localStorage.setItem('locale', locale);
}
